//
//  MRTurntableCell.m
//  MoRan
//
//  Created by MoRan  on 2023.
//  Copyright © 2023年 MoRan . All rights reserved.
//

#import "MRTurntableCell.h"

@implementation MRTurntableCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.tag = 10000;
}

- (void)setData:(id)data delegate:(id)delegate {
    _delegate = delegate;
    
    if ([data isKindOfClass:[NSDictionary class]]) {
        if ([data[@"data"] isKindOfClass:[MRTurntableCellModel class]]) {
            MRTurntableCellModel *model = data[@"data"];
            // 移除之前的子控件
            [_myView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
            
            _customView = [[MRMyCustomView alloc] initWithFrame:CGRectMake(kScreenWidth/2 - 336/2,50, 336, 336) dataList:model.dataList];
            _customView.backgroundColor = [UIColor whiteColor];
            [_myView addSubview:_customView];
        }
    }
}

- (IBAction)buttonAction:(UIButton *)sender {
    if (_delegate && [_delegate respondsToSelector:@selector(turntableCell:buttonAction:)]) {
        [_delegate turntableCell:self buttonAction:sender];
    }
}


@end


#pragma mark - Model

@implementation MRTurntableCellModel

+ (MRTurntableCellModel *)ittemModelWithDataList:(NSArray *)dataList {
    MRTurntableCellModel *model = [MRTurntableCellModel new];
    model.dataList = dataList;
    return model;
}

@end
